<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Specialists extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('specialists', ['id'=>'id', 'comment'=>'专家表', 'engine'=> 'innodb']);
        
        $table->addColumn('user_id', 'integer', ['length'=>10, 'comment'=>'账号id'])
              ->addColumn('name', 'string', ['length'=>100, 'comment'=>'专家名称'])
              ->addColumn('image', 'string', ['comment'=>'专家图片', 'null'=>true])
              ->addColumn('introduce', 'text', ['comment'=>'专家介绍', 'null'=>true])
              ->addColumn('area_id', 'integer', ['length'=>10, 'comment'=>'所属地区id'])
              ->addColumn('crops_category_id', 'integer', ['length'=>10, 'comment'=>'品种id'])
              ->addColumn('type', 'string', ['length'=>10, 'comment'=>'专家类型 Q&A:问答专家, disease:病害', 'default'=>'Q&A'])
              ->addColumn('state', 'integer', ['length'=>5, 'comment'=>'状态 0:禁用, 1:正常', 'default'=>1])
              ->addTimestamps()
              ->create();

    }
}
